<template>
    <div class="bigbig">

        <div id="box">
            <span class="fa fa-angle-left" id="back" @touchstart="back"></span>
            <span id="goods">商品</span>
            <span id="detail">详情</span>
            <span id="say">评价</span>
            <span class="fa fa-mail-forward" id="mail"></span>
        </div>
        <div id="page">
          
            <div id="swiper">
                <Swiper :list="imgs" auto loop auto style="width:100%;margin:0px auto;"></Swiper>
            </div>
            <div id="main">
                <p id="one">{{list.detail}}</p>
                <p id="three">￥{{list.price}}</p>
                <p id="two">支持使用优惠券，波奇豆</p>
                <div id="bottom">
                    <span>已售200</span>
                    <div>
                        <span>|</span>
                        <span id="shou">授</span>
                        <span>授权文件</span>
                    </div>
                </div>

            </div>
            <div id="footer">
                <span id="ling">领劵</span>
                <span class="juan">满499减50</span>
                <span class="juan">满699减100</span>
                <span class="juan">满399减40</span>
            </div>
            <div id="pingjia">
                <div id="quanbu">
                    <span>全部评价(2000)</span>
                    <div>
                        <span>满意度</span>
                        <span id="bai">98%</span>
                    </div>
                </div>
                <div id="last">
                    <div class="last1">
                        <div>
                            <p>whw</p>
                            <p class="first">第一次在波奇购物</p>
                        </div>
                        <div class="star">
                            <span class="fa fa-star"></span>
                            <span class="fa fa-star"></span>
                            <span class="fa fa-star"></span>
                            <span class="fa fa-star"></span>
                            <span class="fa fa-star"></span>
                        </div>
                    </div>
                    <div class="last1">
                        <div>
                            <p>whw</p>
                            <p class="first">第一次在波奇购物</p>
                        </div>
                        <div class="star">
                            <span class="fa fa-star"></span>
                            <span class="fa fa-star"></span>
                            <span class="fa fa-star"></span>
                            <span class="fa fa-star"></span>
                            <span class="fa fa-star"></span>
                        </div>
                    </div>
                </div>
                <div class="last1">
                    <div>
                        <p>whw</p>
                        <p class="first">第一次在波奇购物</p>
                    </div>
                    <div class="star">
                        <span class="fa fa-star nn"></span>
                        <span class="fa fa-star nn"></span>
                        <span class="fa fa-star nn"></span>
                        <span class="fa fa-star nn"></span>
                        <span class="fa fa-star nn"></span>
                    </div>
                </div>
            </div>
            <div id="jiazai">
                <span>查看全部</span>
            </div>
            <div id="zzz">
                <div id="shang">
                    <img src="/static/3.jpg">
                    <span id="five">皇家</span>
                    <span id="six">授权</span>
                    <span id="seven">进入品牌</span>
                </div>
                <div id="xia">
                    <div class="xia1">
                        <p>110</p>
                        <p>全部商品</p>
                    </div>
                    <div class="xia1">
                        <p>102</p>
                        <p>促销商品</p>
                    </div>
                    <div class="xia1">
                        <p>955</p>
                        <p>关注人数</p>
                    </div>
                </div>
            </div>
        </div>
        <div id="go">
            <div id="go1">
                <p class="fa fa-comment nnn"></p>
                <p class="mmm">联系我们</p>
            </div>
            <div id="go2" @touchstart="cart">
                <p class="fa fa-shopping-cart nnn"></p>
                <p class="mmm">购物车</p>
            </div>
            <div id="go3" @touchstart="add">
                加入购物车
            </div>
            <div id="go4">
                立即购买
            </div>
        </div>
    </div>
    </div>

    </div>
</template>

<script>
import { Toast } from 'mint-ui';
import { Swiper } from 'vux';
export default {
    data: function() {
        return {
            list: [],
            imgs: []
        }
    },
    components: {
        Swiper,
    },
    computed: {
        str: function() {
            return this.$route.params.bnm;
        },
    },
    methods: {
        cart:function(){
            location.hash="/cart"
        },
        back: function() {
            history.back()
        },
        add: function() {
            var param = {
                id: this.list._id,
                name: this.list.name,
                detail: this.list.detail,
                price: this.list.price,
                img: this.list.img,
                bigclasses: this.list.bigclasses,
                littleclasses: this.list.littleclasses,
            }

            this.http.post("/api/users/add", param)
                .then(res => {
                    if(res.data.err==0){
                        Toast({
                        message: '添加成功',
                        position: 'middle',
                        duration: 1000
                    });
                    }else{
                         Toast({
                        message: '请先登录',
                        position: 'middle',
                        duration: 1000
                    });
                    }
                    


                })
        }
    },
    activated: function() {
        var param = {
            _id: this.str
        }

        this.http.post("/api/goodsdetail", param).then(res => {
            this.list = res.data.data;
            // console.dir(this.list)
            this.imgs = [];
            for (var i = 0; i < this.list.img.length; i++) {
                var a = {
                    img: this.list.img[i]
                }
                this.imgs.push(a);

            }

        })
    },
    mounted: function() {
        var param = {
            _id: this.str
        }

        this.http.post("/api/goodsdetail", param).then(res => {
            this.list = res.data.data;
            // console.dir(this.list)
            this.imgs = [];
            for (var i = 0; i < this.list.img.length; i++) {
                var a = {
                    img: this.list.img[i]
                }
                this.imgs.push(a);

            }

        })
    }
}
</script>

<style scoped>
.bigbig{
    height: 100vh;
    /* background-color: red; */
}
#page {
    height: 86vh;
       margin-top: 7vh;   
    /* padding-top: 7vh; */
    overflow-y: scroll;
}


#kong {
    width: 100%;
    height: 7vh;
}

#go p {
    margin: 0;
}

.nnn {
    font-size: 20px;
    color: red;
}

.mmm {
    font-size: 12px;
}

#go {
    width: 100%;
    height: 7vh;
    /* border: solid 1px #dbdbdb; */
    display: flex;
    text-align: center;
    position: fixed;
    bottom: 0;
    left: 0;
}

#go1 {
    width: 15vw;
    height: 7vh;
    border-right: solid 1px #dbdbdb;
    background-color: white;
}

#go2 {
    width: 15vw;
    height: 7vh;
    /* border: solid 1px #dbdbdb; */
    background-color: white;
}

#go3 {
    width: 35vw;
    height: 7vh;
    /* border: solid 1px #dbdbdb; */
    line-height: 7vh;
    background-color: orange;
    color: white;
    cursor: pointer;
}

#go4 {
    width: 35vw;
    height: 7vh;
    /* border: solid 1px #dbdbdb; */
    line-height: 7vh;
    background-color: red;
    color: white;
    cursor: pointer;
}

#zzz {
    width: 100%;
    height: 20vh;
    margin-top: 2vh;
    border: solid 1px #dbdbdb;
}

#shang {
    width: 100%;
    height: 10vh;
    /* border: solid 1px #dbdbdb; */
    position: relative;
}

#five {
    font-size: 12px;
    position: absolute;
    top: 3vh;
    left: 17vw;
    ;
}

#six {
    font-size: 8px;
    background-color: #fc4a00;
    color: white;
    padding: 0 1vw;
    position: absolute;
    top: 3vh;
    left: 25vw;
}

#seven {
    font-size: 12px;
    background-color: #fc4a00;
    color: white;
    padding: 1vw 1vw;
    position: absolute;
    top: 2vh;
    right: 2vw;
}

#xia {
    width: 100%;
    height: 10vh;
    /* border: solid 1px #dbdbdb; */
    display: flex;
    text-align: center;
}

img {
    width: 15vw;
    height: 5vh;
    margin-top: 2vh;
}

.xia1 {

    width: 33.3%;
    height: 10vh;
    /* border: solid 1px #dbdbdb; */
}

#pingjia {
    width: 100%;
    height: 28vh;
    margin-top: 2vh;
    background-color: #EFEFEF;
    border: solid 1px #dbdbdb;
}

#jiazai {
    width: 100%;
    height: 7vh;
    text-align: center;
    line-height: 7vh;
    border: solid 1px #dbdbdb;
    border-top: none;
}

#footer {
    width: 100%;
    /* height: 5vh; */
    border: solid 1px #dbdbdb;
    /* margin-top: 2vh; */
}

#quanbu {
    display: flex;
    justify-content: space-between;
    /* border: solid 1px #dbdbdb; */
    height: 7vh;
    line-height: 7vh;
    background-color: white;
    border-top: none;
}

.first {
    font-size: 12px;
}

#bai {
    color: red;
}

.last1 {
    width: 100%;
    height: 7vh;
    border-top: solid 1px #dbdbdb;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

#last .last1 .star span {
    margin-top: 2vh;
    color: orange;
    font-size: 16px
}

.nn {
    margin-top: 2vh !important;
    color: orange;
    font-size: 16px
}

.last1 p {
    margin: 0;
    margin-top: 0.1vh;
}

#one {
    color: #000;
    /* height: 8vh; */
}

#two {
    color: #989898;
    font-size: 14px;
}

#three {
    font-size: 20px;
    color: red;
}

#footer span {
    line-height: 5vh;
}

#ling {
    margin-right: 2vw;
}

.juan {
    font-size: 12px;
    background-color: #fc4a00;
    color: white;
    padding: 0 0.5vw;
}

#bottom #shou {
    font-size: 12px;
    background-color: #fc4a00;
    color: white;
    padding: 0 0.8vw;
    border-radius: 3px;
}

p {
    margin: 0;
    margin-top: 1vh;
    cursor: pointer;
}

span {
    cursor: pointer;
}

#main {
    width: 100%;
    /* height: 22vh; */
    /* border: solid 1px #dbdbdb; */
}

#bottom {
    width: 100%;
    /* height: 5vh; */
    display: flex;
    justify-content: space-between;
    /* border: solid 1px #dbdbdb; */
}

#bottom span {
    line-height: 5vh;
    color: #989898;
    font-size: 14px;
}

#box {
    width: 100%;
    height: 7vh;
    border: solid 1px #dbdbdb;
    position: fixed;
    top: 0;
    z-index: 200;
    background-color: white;
}

#box span {
    line-height: 7vh;
}

#goods {
    margin-left: 20vw;
    font-size: 18px;
}

#detail {
    margin-left: 7vw;
    font-size: 18px;
}

#say {
    margin-left: 7vw;
    font-size: 18px;
}

#back {
    margin-left: 3vw;
    font-size: 30px;
    color: red;
}

#mail {
    margin-left: 10vw;
    color: gray;
}
</style>